import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Rectangle;

import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.xml.stream.events.Comment;

import com.sun.org.apache.xml.internal.security.encryption.Reference;

/**
 * This is option the file controller
 */
public class OptWin extends JFrame  {

	/**
	 * panel option
	 */
	private JPanel optPanel;
	/**
	 * 
	 */
	private JLabel lblOpt;
	private JLabel lblMsg;
	private String msg;
	/**
	 * ok button
	 */
	private JButton btnOK;
	/**
	 * no button
	 */
	private JButton btnNo;
	private int numOfOpt;
	private Object o;
	public volatile int flg = -1;

	
	/**
	 * @return the flg
	 */
	public int getFlg() {
		return flg;
	}

	/**
	 * @param flg the flg to set
	 */
	public void setFlg(int flg) {
		this.flg = flg;
	}
	/**
	 * 
	 * @param s
	 * @param num
	 */
	public OptWin(String s, int num) {
		msg = s;
		numOfOpt = num;
		initialize();
	}
	/**
	 * 
	 * @param s
	 * @param num
	 * @param ob
	 */
	public OptWin(String s, int num , Object ob) {
		o = ob;
		msg = s;
		numOfOpt = num;
		initialize();
	}

	private void initialize() {
		
		optPanel = new JPanel();
		getContentPane().add(optPanel, BorderLayout.CENTER);
		optPanel.setLayout(null);
		
		
		btnOK = new JButton("YES");
		btnOK.setBounds(88, 194, 89, 23);
		optPanel.add(btnOK);
		
		
		btnNo = new JButton("NO");
		btnNo.setBounds(272, 194, 89, 23);
		optPanel.add(btnNo);
		

		lblMsg = new JLabel("Yes/No window");
		lblMsg.setBounds(166, 42, 118, 14);
		optPanel.add(lblMsg);
		
		
		lblOpt = new JLabel(msg);
		lblOpt.setBounds(27, 78, 384, 70);
		optPanel.add(lblOpt);
		
		
		this.setVisible(true);	 
		this.setTitle("Academic Managment Tool");	
		this.setLocation(390, 170);
		this.setSize(500, 300);

		
		switch (numOfOpt)
		{
		case 1:
			case1();
			break;
		case 2:
			case2();
			break;
		}
	}	
	
	
	private void case1()
	{
		btnOK.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				System.out.println("choose yes");
				flg = 1;
				setVisible(false);
			}
		});
		
		defultNo();
	}
	
	
	private void case2()
	{
		btnOK.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				System.out.println("add new class");
				flg = 1;
				setVisible(false);
			}
		});
		
		defultNo();
	}
	
	private void defultNo ()
	{
		btnNo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				setVisible(false);
				System.out.println("back");
				flg = 0;
			}
		});
	}
	
}
